package com.cqqspringcloud.controller;

import com.cqqspringcloud.entiy.Payment;
import com.cqqspringcloud.util.CommentResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
@Slf4j
public class OrderController {
    public static  final String PAYMENT_URL ="http://CLOUD-PAYMENT-SERVICE";
//    public static  final String PAYMENT_URL ="http://localhost:8001";
    @Resource
    private RestTemplate restTemplate;

    @RequestMapping(value = "/consumer/payment/add",method = RequestMethod.PATCH)

    public CommentResult<Payment> create(@RequestBody  Payment payment){
        return  restTemplate.patchForObject(PAYMENT_URL+"/payment/add",payment,CommentResult.class);
    }

  @GetMapping("/consumer/payment/getOne/{id}")
    public CommentResult<Payment>getpayMent(@PathVariable("id") Long id){
        return  restTemplate.getForObject(PAYMENT_URL+"/payment/getOne/"+id,CommentResult.class);
    }
}
